package com.weike.yuanding.strategy.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.weike.yuanding.constant.UserVideoRelationEnum;
import com.weike.yuanding.core.domain.R;
import com.weike.yuanding.dto.user.UserFriendDTO;
import com.weike.yuanding.entity.VideoMainEntity;
import com.weike.yuanding.feign.user.UserService;
import com.weike.yuanding.mapper.VideoMainMapper;
import com.weike.yuanding.service.VideoService;
import com.weike.yuanding.strategy.VideoStrategy;
import com.weike.yuanding.utils.BaseContext;
import com.weike.yuanding.vo.VideoResVo;
import com.weike.yuanding.vo.VideoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 作品视频策略
 */
@Component("5")
public class ZuoPinVideoStrategy implements VideoStrategy {

    @Autowired
    private VideoMainMapper videoMainMapper;

    @Autowired
    private VideoService videoService;

    @Autowired
    private RedisTemplate<String, Object> redisTemplate;
    @Autowired
    private UserService userService;

    /**
     *
     * @param videoVo 输入参数
     * @return
     */
    @Override
    public List<VideoResVo> getVideoList(VideoVo videoVo) {
        String userId = videoVo.getUserId();

//        PageHelper.startPage(videoVo.getPageNumber() , videoVo.getPageSize());


        List<VideoMainEntity> videoMainEntities  = videoMainMapper.selectList(new LambdaQueryWrapper<VideoMainEntity>()
                .eq(VideoMainEntity::getUserId , userId));

//        PageHelper.clearPage();
        return videoService.list(videoMainEntities.stream().map(VideoMainEntity :: getVideoId).collect(Collectors.toList()));
    }

}
